﻿package com.alipay.config;

import java.io.FileWriter;
import java.io.IOException;

/* *
 *类名：AlipayConfig
 *功能：基础配置类
 *详细：设置帐户有关信息及返回路径
 *修改日期：2017-04-05
 *说明：
 *以下代码只是为了方便商户测试而提供的样例代码，商户可以根据自己网站的需要，按照技术文档编写,并非一定要使用该代码。
 *该代码仅供学习和研究支付宝接口使用，只是提供一个参考。
 */

public class AlipayConfig {
	
//↓↓↓↓↓↓↓↓↓↓请在这里配置您的基本信息↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

	// 应用ID,您的APPID，收款账号既是您的APPID对应支付宝账号
	public static String app_id = "9021000137666800";
	
	// 商户私钥，您的PKCS8格式RSA2私钥
    public static String merchant_private_key = "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCF9uF+dOMkUzg21zHI3ticUOdNSuON6h7+y5voXi1QRVffla4knfWIoOwC6RXUlcsrqV8C5wVO8N699IEwvS+XJIfinRUqHReUFgcZR1Gd32cpAH+KGh27Aah3VBLvRYCWCy9WNimXu4TL9Mj+nZmNT8Y+EH6v1ITS9Ic2sucl8ghOEZbpPCXjaDqZlaCkEmq40uGsOvn/GW0PoxufvRbFycs1okJgzVHBfpKaIVc3av9Cneo+oIx5cCa4upI8A7nya7uew+P2Sbh1IRgu7vQo7guUi9EKV2NVwqGqsRrs/b5dJEODA/7X4jrbNUyWSgYH8nCyfQ4gi7WpVrMA3tU1AgMBAAECggEAAkI8YRZ1cfpZO0t7kmh3fIM8syftGEp3RVKHiW51EyJoLePnMMTdC/WypQXrEU+JQm4zpOfiRgd3qfpCZ2D5OXIrPF3rqm8dI6kPa5SxQpkusxlIDTsNf0ay4XgwbYpddaownSKCpwVJYur4rJpZqXFL5WX/zNUnfCsVUI3JqfEZWICTNXNRq/1qoaRmLpiVTBshTa1d2p4DzWW5qWvMns9bz5GiMVhrNpRyHvKLEFWwnsgETtAtV0F8vpGkgnZwhYdd5PwN51ZePJkQ2ZxkAS05k0V4OBPvmHB2sjS2KK52sZz1k7vd27GmpeIbJ0E7LROv8iCgkQSMczJUonTozQKBgQDq+8+VEHH4yp3G+Y8lvu8yeeaBXcPQ+ap60x5KTNUaaI1dgY8SKkZVkQttXbKChkyKabRsYvGu8JHv/q/wkLUv9v8vd7YgGNjrUeKDQz0XGO8fqiSYMPVRxh/oDQXNKW7KDC13y0yfAN/TQJTiGNKeESSzy1BBh74ToLZ6VnDR8wKBgQCR8iGjx/ynHhlPAcjlPBHebZ9dkjDXAyWj1cPRwNg46/PFSwYJwoxqd2vNG9g9b9gJtGRCICVyZp68KHXg5E94JoqRKwEMhRwbc5C457NXt+gLE6F9h5DxRXx3qlEZFTH3T2w15UDaCLOOZsngj3KsPJG6oROeHNS027tdyGveNwKBgEplURJjs4HOPGe7qTuNGNQFThpVImLuOLBMWQGzE6EZyu/4zeA1bDE5C8IjcRnsBR2pW8sZBGWbmsi9/NwQJJ07+Q0BPLMqyrquISXnytaeOU7wIkfg8DpknMNuJBERdhcYBekwf2Cz+Sk8ACcZLs2GpfUagJ1OqbozHrLa3TtLAoGBAIxnLAWsN1tukVp4lRQzHd2mCFK0eVfgJy3eUGxR4bGhDPsYmc554yvph0PjLbytBGERsgILevr7zmmlYwHforQsH9JYVMH+rHOcUfYQsXAJ9KnzUMC60q3J81wL9cjzowYQ2kFfM2yOQm8UY9ItLlyUSH4KyBysD9WOLkqirWMxAoGANyfVW5ozrJh78zK1GuhikjMUWl9mdXuRVBWo6J4H+V3VIdiT8bNTljV/oO8Ndv6SrZquVH37cIg0054A+eMz3vHWAPo6wJkofQ0X4MKR8mTM0p9iKbuh0+0XtQ1RlfVHgtqNqwOA/vZW2LgdcHMWdJwOeT1nrKN2hMn2KfzWNqE=";
	
	// 支付宝公钥,查看地址：https://openhome.alipay.com/platform/keyManage.htm 对应APPID下的支付宝公钥。
    public static String alipay_public_key = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvVZwOeJJyguYXMaWrk2nxj4n9BmWjpxKISO+1KeuRrqlFLm9aqFfdoxryDRUd2xb0/4eL3k3eQoDOEBNbMs1lfyxjpQH1jcOz0XPO1gYw+D2z0qD83E0Lz9W3LpV1XNbdZ40ScjTh+CJSjn+kxy/S1X+V6jlUXt1qVCOgVUtb6+01Mt1JS6dUrxSJY+YaxCg/r6dJlAKd2D9nZwIEmmpokcDvRNMJlO4bZ50LNovseokxGQbn5feyP6ZK8Mb/SPh/qM3ssG6oe79CYCTP7QnLtuxCYBqGrE0nFm69BjKezYul53u2rNLdY9CwEdKkJRLPt7ewL4pzUqXzsIP6mA8HwIDAQAB";

	// 服务器异步通知页面路径  需http://格式的完整路径，不能加?id=123这类自定义参数，必须外网可以正常访问
	public static String notify_url = "http://localhost/fruitmarket/notify_url.jsp";

	// 页面跳转同步通知页面路径 需http://格式的完整路径，不能加?id=123这类自定义参数，必须外网可以正常访问
	public static String return_url = "http://localhost/fruitmarket/return_url.jsp";

	// 签名方式
	public static String sign_type = "RSA2";
	
	// 字符编码格式
	public static String charset = "utf-8";
	
	// 支付宝网关
	public static String gatewayUrl = "https://openapi-sandbox.dl.alipaydev.com/gateway.do";
	
	// 支付宝日志地址
	public static String log_path = "C:\\";


//↑↑↑↑↑↑↑↑↑↑请在这里配置您的基本信息↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑

    /** 
     * 写日志，方便测试（看网站需求，也可以改成把记录存入数据库）
     * @param sWord 要写入日志里的文本内容
     */
    public static void logResult(String sWord) {
        FileWriter writer = null;
        try {
            writer = new FileWriter(log_path + "alipay_log_" + System.currentTimeMillis()+".txt");
            writer.write(sWord);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (writer != null) {
                try {
                    writer.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}

